package com.dorm.cj.extension.beanInitialize;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * bean初始化三种方式：(按照调用顺序排序)
 * <p>
 * 1使用@PostConstruct注解
 * 2实现InitializingBean接口
 * 3xml中指定init-method方法
 */
@Service
public class TestBeanInitialize implements InitializingBean {

    @PostConstruct
    public void init() {
        System.out.println("-------- @PostConstruct----------");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("-------- afterPropertiesSet----------");
    }

    public void test() {
        System.out.println("---test-----");
    }
}
